import { create } from '../asyncActionCreator';

export const TypeOption = {
	InviteTeacher: 0,
	Telephhone: 1,
	InviteCode: 2
};

export const INVITE_TEACHER_DATA_URL = '/api/data/ActivityAnalysisInviteTeacher';
export const INVITE_TELEPHONE_DATA_URL = '/api/data/ActivityAnalysisTelephone';
export const INVITE_CODE_DATA_URL = '/api/data/ActivityAnalysisInviteCode';

export const GET_INVITE_DATA_REQUEST = 'request invite chart data';
export const GET_INVITE_DATA_SUCCESS = 'request invite chart data success';
export const GET_INVITE_DATA_FAILURE = 'request invite chart data failure';

export const getInviteDataRequest = (key) => ({
	type: GET_INVITE_DATA_REQUEST,
	payload: { 
		key 
	}
});

export const getInviteDataSuccess = (key, data) => ({
	type: GET_INVITE_DATA_SUCCESS,
	payload: {
		key,
		data
	}
});

export const getInviteDataFailure = (key, message) => ({
	type: GET_INVITE_DATA_FAILURE,
	payload: {
		key,
		message
	}
});

export const getInviteData = (url, key, params) => (create(
	url,
	getInviteDataRequest.bind(null, key),
	getInviteDataSuccess.bind(null, key),
	getInviteDataFailure.bind(null, key),
	params
));